//地址列表页
var common = require('../../utils/common');
Page({
  data: {
    addressList: '',
    curAddrId: ""
  },
  onShow: function() {
    this.getAddressList();
  },
  getAddressList() {
    common.getAddress().then(res => {
      this.setData({
        addressList: res.data
      })
    })
  },
  goToEditAddr: function(e) {
    var addrInfo = e.currentTarget.dataset.addrinfo;
    if (addrInfo != undefined) {
      wx.setStorage({
        key: 'curAddrInfo',
        data: addrInfo,
        success: () => {
          wx.navigateTo({
            url: 'editAddr?addrId=' + e.currentTarget.dataset.id + '&&addrType=0'
          })
        }
      })
    } else {
      wx.navigateTo({
        url: 'editAddr?addrId=' + e.currentTarget.dataset.id + '&&addrType=0'
      })
    }
  }
})